function [X,Y,Z,pillarmatrep]=determCORNERPOINTcord(grdecl)
NI=grdecl.cartDims(1);
NJ=grdecl.cartDims(2);
NK=grdecl.cartDims(3);

zcorn=grdecl.ZCORN;

pillarmat=reshape(1:(NI+1)*(NJ+1),[(NI+1),(NJ+1)]);
plf=pillarmat(1:NI,1:NJ);% lf=左前
prf=pillarmat(2:NI+1,1:NJ);% rf=右前
plb=pillarmat(1:NI,2:NJ+1);% lb=左后
prb=pillarmat(2:NI+1,2:NJ+1);% rb=右后
pillarmatrepxy=zeros(2*NI,2*NJ);
pillarmatrepxy(1:2:end,1:2:end)=plf;
pillarmatrepxy(2:2:end,1:2:end)=prf;
pillarmatrepxy(1:2:end,2:2:end)=plb;
pillarmatrepxy(2:2:end,2:2:end)=prb;
pillarmatrep=repmat(pillarmatrepxy,1,1,2*NK);

COORD=grdecl.COORD;
coord=reshape(COORD,6,[]).';
% pcord按ZCORN中的顺序，在每一行给出每个角点所在柱线的两端点坐标
pcord=coord(pillarmatrep(:),:);
% 纠正角点坐标-pcord
tol=1000*eps;
clps=abs(pcord(:,3)-pcord(:,6))<tol;
intpk=(zcorn(:) - pcord(:,3)) ./ (pcord(:,6) - pcord(:,3));
intpk(clps)=0;
xcord=pcord(:,1)+intpk.*(pcord(:,4)-pcord(:,1));
ycord=pcord(:,2)+intpk.*(pcord(:,5)-pcord(:,2));

% 按ZCORN的顺序
% pcord=[xcord,ycord,zcorn];
X=reshape(xcord,2*[NI,NJ,NK]);
Y=reshape(ycord,2*[NI,NJ,NK]);
Z=reshape(zcorn,2*[NI,NJ,NK]);